package com.ruoyi.system.api.factory;

import com.ruoyi.system.api.RemoteAiModelService;
import com.ruoyi.system.api.domain.AipptOutline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;

/**
 * 文件服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteAiModelFallbackFactory implements FallbackFactory<RemoteAiModelService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAiModelFallbackFactory.class);

    @Override
    public RemoteAiModelService create(Throwable throwable)
    {
        log.error("ai服务调用失败:{}", throwable.getMessage());
        return new RemoteAiModelService()
        {

            @Override
            public String chat(String message, String userid){
                return "获取ai消息失败";
            };
            @PostMapping("/chatPost")
            public String chatPost(@Valid @RequestBody AipptOutline aipptOutline) {
                return "获取ai消息失败";
            }
        };
    }
}
